@extends('layouts.back_stage')
@section('content')
    <link href="{{env('CDN_DOMAIN_NAME')}}/store/commoncss/simplePagination.css" rel="stylesheet">
    <style>
        .address {
            border-color: #cfdadd;border-radius: 2px;width: 150px;
            height: 30px;padding: 6px 10px;font-size: 13px;line-height: 1.42857143;margin-right:10px;
            color: #555;background-color: #fff;background-image: none;border: 1px solid #cfdadd;box-shadow: none;
            -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        }
        .form-control, .single-line{font-size:13px;}
    </style>
    <!-- 退货店铺-->
    <div class="container">
        <div style="padding:20px 0;"><h3>退货店铺列表</h3></div>
        <div class="pull-left" style="width: 100%;margin-bottom:20px;">
            <label>店铺名：</label>
            <input type="text" class="form-control shop_name" placeholder="请输入店铺名" style="width:150px;display: inline-block">
            <label>负责人：</label>
            <input type="text" class="form-control shopowner_name" placeholder="请输入负责人" style="width:150px;display: inline-block">
            <label>店铺类型：</label>
            <select class="address shop_type">
                <option value="">请选择店铺类型</option>
                <option value="1">直营店</option>
                <option value="2">联营店</option>
                <option value="3">加盟店</option>
            </select>
            <label>状态：</label>
            <select class="address is_new">
                <option value="">请选择状态</option>
                <option value="-1">未核对</option>
                <option value="1">已核对</option>
            </select>
            <button onclick="souSan()" class="btn btn-info" style="margin-bottom:4px;">搜索</button>
            <button onclick="reSetScan()" class="btn btn-info" style="margin-bottom:4px;">清空</button>
        </div>
        <table class="table table-hover">
            <thead>
            <tr>
                <th>店铺名</th>
                <th>负责人</th>
                <th>店铺类型</th>
                <th>地址</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <div id="paging1" class="page" style=""></div>
    </div>
    <!-- /退货店铺-->
    <script src="{{ env('CDN_DOMAIN_NAME') }}/store/commonjs/jquery.simplePagination.js?v0.0.3"></script>
    <script>
        /*搜索*/
        function souSan(){
            skip=1;
            pervNextSerach();
        };
        /*清空*/
        function reSetScan(){
            skip=1;
            $('.form-control').val("");
            $('.address').val("");
            pervNextSerach();
        };
        /*点击分页*/
        $(document).on('click','.page-link',function(){
            if($(this).attr('class') === "page-link next nextPage"){
                if($(this).parent().attr('class') == 'active'){
                    return false;
                }else{
                    skip=Number(skip)+1;
                    pervNextSerach();
                }
            }else if($(this).attr('class') === "page-link prev prevPage"){
                if($(this).parent().attr('class') == 'active'){
                    return false;
                }else{
                    skip=Number(skip)-1;
                    pervNextSerach();
                }
            }else if($(this).attr('class') === "page-link tcdNumber"){
                skip=Number($(this).text());
                pervNextSerach();
            }
        });
        /*页面初始化*/
        var skip = 1;
        pervNextSerach();
        function pervNextSerach(){
            var shop_name = $('.shop_name').val();
            var shopowner_name = $('.shopowner_name').val();
            var shop_type = $('.shop_type').val();
            var is_new=$('.is_new').val();
            $.ajax({
                url:'/warehouse/return-shop-lists',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                dataType:'json',
                data:{
                    skip:skip,
                    shop_name:shop_name,
                    shopowner_name:shopowner_name,
                    shop_type:shop_type,
                    is_new:is_new
                },
                success:function(data){
                    console.log(data);
                    if(data.result.success){
                        $('.table tbody').empty();
                        var res=data.content.content;
                        if(res.length>0){
                            for(var i in res){
                                if(res[i].shop_type==1){
                                    var types='直营店';
                                }else if(res[i].shop_type==2){
                                    var types='联营店';
                                }else if(res[i].shop_type==3){
                                    var types='加盟店';
                                }
                                if(res[i].is_new==-1){
                                    var status='<td>未核对</td>';
                                }else if(res[i].is_new==1){
                                    var status='<td style="color:#ccc;">已核对</td>';
                                }
                                var str='<tr>' +
                                    '<td>'+res[i].shop_name+'</td>' +
                                    '<td>'+res[i].shopowner_name+'</td>' +
                                    '<td>'+types+'</td>' +
                                    '<td>'+res[i].address_details+'</td>' +status+
                                    '<td>' +
                                    '<a href="/warehouse/inventory-return-shop-details/'+res[i].id+'">详情</a>' +
                                    '</td>' +
                                    '</tr>';
                                $('.table tbody').append(str);
                            }
                        }else{
                            $('.table tbody').append("<tr><td class='text-center' colspan='6'>无数据</td></tr>");
                        }
                        $("#paging1").pagination({
                            items: data.content.total,
                            itemsOnPage: 10,
                            cssStyle: 'light-theme',
                            currentPage:data.content.skip
                        });
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.result.errorMsg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            });
        }
    </script>
@endsection
